﻿@model IList<CategoryNavigationModel>
@using Nop.Core.Domain.Catalog
@using Nop.Core.Infrastructure
@using Nop.Services.Catalog
@using Nop.Web.Models.Catalog
@{
    var categoryPadding = 15;
}
@if (Model.Count > 0)
{
    <script type="text/javascript">
        var menuShow = false;
        function menuClose() {
            if (menuShow) return;
            $("#naver").addClass("hidden");
            $("#subnav li").removeClass("current");
            $("#submenu li").removeClass("current");
            $(".cats").addClass("hidden");
        }
        $(document).ready(function () {

            $("#subnav li").mouseover(function () {
                if ($.trim($("#cat" + this.id).text()) != "") {
                    menuShow = true;

                    $("#naver").removeClass("hidden");
                    $("#subnav li").removeClass("current");
                    $(this).addClass("current");
                    $(".cats").addClass("hidden");
                    $("#cat" + this.id).removeClass("hidden");
                    $("#naver").css("left", $("#submenu").position().left + $("#subnav").outerWidth() - 3);
                    $("#naver").css("top", $(this).position().top);
                }
            });
            $("#subnav").mouseout(function () {
                menuShow = false;
                setTimeout(menuClose, 1000);
            });
            $("#naver").mouseover(function () {
                menuShow = true;
            });
        });
    </script>
    <div class="block block-category-navigation">
        <div class="title">
            @T("Categories")
        </div>
        <div class="clear">
        </div>
        <div id="subnav" class="listbox">
            <ul id="submenu">
                @foreach (var category in Model)
                {
                    if (category.NumberOfParentCategories <= 0)
                    {
                        <li id="parentcat@(category.Id)" class="@(category.IsActive ? "active" : "inactive") @Html.Action("ParentCategoryClass", "Catalog", new { categoryId = category.Id })" 
                        @*@if (category.NumberOfParentCategories > 0)
                        {
                            if (this.ShouldUseRtlTheme())
                            {
                            <text>style="margin-right: @(category.NumberOfParentCategories * categoryPadding)px"</text>
                            }
                            else
                            {
                            <text>style="margin-left: @(category.NumberOfParentCategories * categoryPadding)px"</text>
                            }
                        }*@
                        ><a href="@Url.RouteUrl("Category", new { categoryId = category.Id, SeName = category.SeName })">@category.Name
                            @if (category.DisplayNumberOfProducts)
                            {
                                <text> (@(category.NumberOfProducts))</text>
                            }
                        </a></li>
                    }
                }
            </ul>
            <div class="  hidden" id="naver">
                <div class="wrapper">
                    @foreach (var category in Model)
                    {
                        if (category.NumberOfParentCategories <= 0)
                        {
                             @Html.Action("SubCategoryNavigation", "Catalog", new { categoryId = category.Id })
                        }
                    }

                </div>
            </div>
        </div>
    </div>
    
}